'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: 12_simple_use_lcel.py
* @Time: 2025/10/23
* @All Rights Reserve By Brtc
'''
import dotenv
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import PromptTemplate, ChatPromptTemplate
from langchain_openai import ChatOpenAI

dotenv.load_dotenv()

#1、构建提示词
prompt = ChatPromptTemplate.from_template("{query}")
llm = ChatOpenAI(model="gpt-4o-mini")
parser = StrOutputParser()

#2、创建链
chain = prompt | llm | parser
print(chain.invoke({"query":"请讲一个关于程序员的笑话？"}))

